import React, { Component, PropTypes } from 'react';
import { connect } from 'dva';
import RoomList from '../../components/Wilddog/RoomList'
import { Card } from 'antd';

function WilddogUp({location, dispatch, wilddog }) {
  const {roomList, auth} = wilddog; 

  const roomListProps = {
    roomList,
    auth,
    addOneRoom(item){
    	dispatch({
    		type:'wilddog/addOneRoom',
    		payload:item
    	})
    }
  };
  // console.log(auth)
  let login = function() {
    dispatch({
      type: 'wilddog/login'
    })
  }
  return (<div className='content-inner'>
     {
     	auth.status? <RoomList {...roomListProps} />: <Card title="点击登录" onClick={login} style={{ width: 300 }}><p >暂未检测到登录状态</p></Card>
     }
    </div>)
}

function mapStateToProps({ wilddog }) {
  return { wilddog }
}
export default connect(mapStateToProps)(WilddogUp)

WilddogUp.propTypes = {
  wilddog: PropTypes.object.isRequired
}
